package swingtest;

import java.awt.Color;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.PopupMenu;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class J_FlowBoxLayout {

	public static void main(String[] args) {
		JFrame app = new JFrame("J_FlowBoxLayout");
		app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		app.setSize(215, 150);
		Container container = app.getContentPane();
//		container.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
		container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS));

		JPanel[] p = new JPanel[3];
		int i = 0;
		for (i = 0; i < p.length; i++) {
			p[i] = new JPanel();
			p[i].setLayout(new BoxLayout(p[i], BoxLayout.X_AXIS));

			container.add(p[i]);
		}

		int pj[] = { 0, 1, 1, 2, 2, 2 };
		for (i = 0; i < pj.length; i++) {
			p[pj[i]].add(new JButton("button" + i));
		}

		app.setVisible(true);
	}

}
